﻿using UnityEngine;
using System.Collections;

public class Block : MonoBehaviour {

    private float xOffset = -2.3f;
    private float yOffset = -3.5f;
    private float delatXOffset = 1.55f;
    private float delatYOffset = 2.55f;
    public int columnIndex, rowIndex;
    private GameManager game;
    public bool isCanTouch = true;
    // Use this for initialization
    void Start () {
        game = GameObject.FindObjectOfType<GameManager>();
    }
	
	// Update is called once per frame
	void Update () {
	
	}

    void OnMouseDown()
    {
        game.SelectBlock();
        if (isCanTouch)
        {
            GameManager.score += 1;
        }
        else
        {
            GameManager.score -= 5;
        }

    }

    public void MoveBlock(int columnIndex,int rowIndex)
    {
        this.columnIndex = columnIndex;
        this.rowIndex = rowIndex;
        print(rowIndex);
        gameObject.transform.position = new Vector3(xOffset + columnIndex * delatXOffset, yOffset + rowIndex * delatYOffset, 0);
    }

    public void MoveDown()
    {
        MoveBlock(columnIndex, rowIndex - 1);
    }
}
